#include "jost/Array.hpp"

jost::Array::Array() throw()
    : jost::Value(jost::Value::ARRAY)
{}

jost::Array::~Array() throw()
{
    std::vector<jost::Value*>::iterator index
        = this->begin();
    std::vector<jost::Value*>::iterator end
        = this->end();

    while (index != end) {
        delete *index;
        ++index;
    }
}


std::string
jost::Array::serialize() throw()
{
    std::vector<jost::Value*>::iterator index
        = this->begin();
    std::vector<jost::Value*>::iterator end
        = this->end();
    
    std::string str = "[";

    if (this->size() != 0)
    {
        while (index != (end -1))
        {
            str += (*index)->serialize();
            str += ",";
            index++;
        }
        str += (*index)->serialize();
    }
    
    str += "]";
    return str;
}
